<?php

/**
 * 
 **/
class PasswordValidator extends sfValidatorBase
{
  public function configure($options = array(), $messages = array())
  {
    $this->addMessage('fit', '您输入的旧密码错误');
  }

  public function doClean($values)
  {
    if (!$values['old_password'])
    {
      return $values; // do not check
    }
    // else
    $user = sfContext::getInstance()->getUser();
    if ($user->checkPassword($values['old_password']))
    {
      return $values;
    }
    // else
    throw new sfValidatorError($this, 'fit');
  }
}
